//
//  FuncViewController.m
//  LibDemo
//
//  Created by Gikki Ares on 2020/9/5.
//

#import "NavMenuViewController.h"
#import <JsUtilitySdk/JsTableView.h>
#import <JsUtilitySdk/JsMenuView.h>
#import <JsUtilitySdk/JsRequestManager.h>
#import <JsUtilitySdk/JsDisplayManager.h>
#import <JsUtilitySdk/JsGeometryManager.h>
#import <JsUtilitySdk/JsRequestManager.h>
#import <JsUtilitySdk/JsColorManager.h>

@interface NavMenuViewController ()<
JsMenuViewDelegate
>
{
	JsTableView * mTableView;
	UITextView * mtv;
}

@end

@implementation NavMenuViewController

- (void)viewDidLoad {
	[self setupUi];
}

- (void)setupUi {
	self.view.backgroundColor = [UIColor whiteColor];
	{
		CGRect rect = [JsGeometryManager frameHAlignLeftVAlignTopWithContainerSize:CGSizeZero size:CGSizeMake(JsGeometryManager.screenWidth, 220) offset:CGPointMake(0, 0)];
		
		JsMenuView * menuView = [[JsMenuView alloc]initWithFrame:rect];
		menuView.backgroundColor = [UIColor lightGrayColor];
		menuView.delegate = self;
		//决定self.view是否从导航栏下方开始.
		self.edgesForExtendedLayout = UIRectEdgeNone;
		[self.view addSubview:menuView];
	}
}

- (void)viewDidLayoutSubviews {
	[super viewDidLayoutSubviews];
}

# pragma mark 4 Delegate
- (NSArray<JsMenuItemVm *> *)jsMenuViewSetDatasource:(JsMenuView *)view {
	return @[
		[[JsMenuItemVm alloc] initWithTitle:@"边看边聊"],
		[[JsMenuItemVm alloc] initWithTitle:@"相关新闻"],
		[[JsMenuItemVm alloc] initWithTitle:@"图文直播"],
	];
}

//imageHeight = 120,labelHeight = 30;
- (JsMenuItemStyle *)jsMenuView:(JsMenuView *)menuView setUnselectedStyleForCellAtIndex:(int)index {
	JsMenuItemStyle * style = [JsMenuItemStyle defaultStyle];
	style.cellSize = CGSizeMake(100,40);
	return style;
}

- (JsMenuItemStyle *)jsMenuView:(JsMenuView *)menuView setSelectedStyleForCellAtIndex:(int)index {
	JsMenuItemStyle * style = [JsMenuItemStyle defaultStyle];
	style.cellSize = CGSizeMake(100,40);
	style.titleColor = [UIColor whiteColor];
	return style;
}

- (JsMenuViewStyle *)jsMenuViewSetStyle:(JsMenuView *)view {
	JsMenuViewStyle * style = [JsMenuViewStyle defaultStyle];
	int marginV = (220 - 40) / 2;
	int marginH = (JsGeometryManager.screenWidth - 100 * 3)/4;
	style.edgeInset = UIEdgeInsetsMake(marginV, marginH, marginV, marginH);
	style.isShowChooseMaskView = YES;
	style.maskViewColor = [UIColor colorMax255WithR:200 g:174 b:94 a:100];
	style.initialSelectedIndex = 0;
	return style;
}

- (void)jsMenuView:(JsMenuView *)view clickMenuAtIndex:(int)index vm:(JsMenuItemVm *)vm {
	NSLog(@"%d",index);
}



@end
